using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ClimbTracker.BusinessLogic.Entities;
using ClimbTracker.GUI.TabControls;

namespace ClimbTracker.GUI
{
    public partial class MainMDIForm : Form
    {

        #region Members

        private int _activeCompetitionID = -1;
        private int _activeCompetitorID = -1;
        private int _activeRouteID = -1;

        private Competitor _activeCompetitor = new Competitor();
        private Route _activeRoute = new Route();




        // Tab controls
        private CompetitorsTabControl _competitorsTabControl = new CompetitorsTabControl();
        private RoutesTabControl _routesTabControl = new RoutesTabControl();
        private TrackingTabControl _trackingTabControl = new TrackingTabControl();

        private ClimbTrackerDataSet.routesDataTable _routesTable;


        #endregion


        #region Getters and Setters

        public int ActiveCompetitionID
        {
            get { return _activeCompetitionID; }
            set { _activeCompetitionID = value; }
        }
        public int ActiveCompetitorID
        {
            get { return _activeCompetitorID; }
            set { _activeCompetitorID = value; }
        }
        public int ActiveRouteID
        {
            get { return _activeRouteID; }
            set { _activeRouteID = value; }
        }
        public Competitor ActiveCompetitor
        {
            get { return _activeCompetitor; }
            set { _activeCompetitor = value; }
        }
        public Route ActiveRoute
        {
            get { return _activeRoute; }
            set { _activeRoute = value; }
        }


        public CompetitorsTabControl CompetitorsTabControl
        {
            get { return _competitorsTabControl; }
            set { _competitorsTabControl = value; }
        }
        public RoutesTabControl RoutesTabControl
        {
            get { return _routesTabControl; }
            set { _routesTabControl = value; }
        }
        public TrackingTabControl TrackingTabControl
        {
            get { return _trackingTabControl; }
            set { _trackingTabControl = value; }
        }
        public ClimbTrackerDataSet.routesDataTable RoutesTable
        {
            get { return _routesTable; }
            set { _routesTable = value; }
        }

        #endregion




        public MainMDIForm()
        {
            InitializeComponent();
            _trackingTabControl.setCompetitorTab(_competitorsTabControl);
        }


        private void MainMDIForm_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'climbTrackerDataSet.competitors' table. You can move, or remove it, as needed.
            this.competitorsTableAdapter.Fill(this.dataSet.competitors);
            // TODO: This line of code loads data into the 'climbTrackerDataSet.routes' table. You can move, or remove it, as needed.
            this.routesTableAdapter.Fill(this.dataSet.routes);


            // Assign the tables which we will actually use
            this.RoutesTable = routesTableAdapter.GetData();

            CompetitorsTabControl.Dock = DockStyle.Fill;
            RoutesTabControl.Dock = DockStyle.Fill;
            TrackingTabControl.Dock = DockStyle.Fill;           
            

            // Add content to the tabs
            competitorsTabPage.Controls.Add(CompetitorsTabControl);
            routesTabPage.Controls.Add(RoutesTabControl);
            trackingTabPage.Controls.Add(TrackingTabControl);
        }



        private void tabContainer_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabContainer.SelectedTab.Equals(routesTabPage))
            {
                this.RoutesTabControl.onTabSelected();
            }
            if (tabContainer.SelectedTab.Equals(trackingTabPage))
            {
                TrackingTabControl.onTabSelected();

            }
        }


    }
}